﻿<script type="text/javascript">
    deleteOverlays();
    bounds = new google.maps.LatLngBounds();

    $("#user-rentals a.sort-method").click(function () {
        var sortMethod = $(this).text();
        $.post("/Rental/FilterUserRentals?sort=" + sortMethod + "&incFilter=" + userFilterSubmit, $("#user-rentals-filter-form").serialize(), function (data) {
            $("#user-rentals-list").html(data);
        });
    });

    //Don't included idle filter values if not submitted
    var userFilterSubmit = false;
    $("#user-rentals-filter-form").submit(function () {
        userFilterSubmit = true;
    });
</script>

<div id="user-rentals-options">
    <span class="hide-option"><a href="#" onclick="toggleSidebar()">&laquo;&nbsp;Hide</a></span>
    <span class="filter-option"><a href="#" onclick="$('#user-rentals-options #filter').toggle();$('#user-rentals-options #sort').hide();">Filter&nbsp;&raquo;</a></span>
    <div id="filter">
        @using (Ajax.BeginForm("FilterUserRentals", "Rental", new { incFilter = "true" }, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "user-rentals-list" }, new { id = "user-rentals-filter-form" }))
        {
            @Html.ValidationSummary(true)
        
            @Html.Action("Filter")
        }
    </div>

    <span class="sort-option"><a href="#" onclick="$('#user-rentals-options #sort').toggle();$('#user-rentals-options #filter').hide();">Sort&nbsp;&raquo;</a></span>
    <div id="sort">
        <ul>
            <li>
                <a href="#" class="sort-method">Rent</a>
            </li>
            <li>
                <a href="#" class="sort-method">Bedrooms</a>
            </li>
        </ul>
    </div>
</div>

<div id="user-rentals-list">
    @Html.Action("FilterUserRentals")
</div>